<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:p="http://primefaces.org/ui" 
      xmlns:ui="http://java.sun.com/jsf/facelets">


    <h:form id="formTabela">
        <p:growl id="growl" showDetail="false" />
        <p:dataTable id="listContasPagar" var="forn" value="#{empresaControler.listEmpresa}" widgetVar="carsTableAtivos" 
                     rowKey="#{forn.id}" selectionMode="single"  emptyMessage="Nenhum registro foi encontrado!" 
                     paginator="true" rows="10" rowsPerPageTemplate="5,10,15" selection="#{empresaControler.empresa}">
            <p:ajax event="rowSelect"    
                    update=":formCadastroEmpresa" oncomplete="dlgEmpresa.show()" />  
            <p:ajax event="rowUnselect" update="@form" />  

            <f:facet name="header" >  
                <p:outputPanel>  
                    <p:commandButton value="Adicionar novo" accesskey="N" onclick="dlgEmpresa.show()" action="#{empresaControler.inicializaObj()}" 
                                     update=":formCadastroEmpresa" process="@this" style="float: left;"/>
                    <h:outputText value="Digite para pesquisar " />
                    <p:inputText id="globalFilter" onkeyup="carsTableAtivos.filter()" style="width:150px" /> 
                </p:outputPanel>  
            </f:facet>  
            <p:column filterBy="${forn.razaoSocial}" headerText="Razão Social" footerText="Razão Social" sortBy="${forn.razaoSocial}">    
                <h:outputText value="${forn.razaoSocial}" />  
            </p:column>  
            <p:column filterBy="${forn.nomeFantasia}" headerText="Fantasia" footerText="Fantasia" sortBy="${forn.nomeFantasia}">    
                <h:outputText value="${forn.nomeFantasia}" />  
            </p:column>  
            <p:column filterBy="${forn.cnpj}" headerText="CNPJ" footerText="CNPJ" sortBy="${forn.cnpj}">    
                <h:outputText value="${forn.cnpj}" />  
            </p:column>  
            <p:column filterBy="${forn.inscricaoEstadual}" headerText="Insc. Estadual" footerText="Insc. Estadual" sortBy="${forn.inscricaoEstadual}">    
                <h:outputText value="${forn.inscricaoEstadual}" />  
            </p:column>  

        </p:dataTable>
        <p:separator/>
    </h:form>

    <p:dialog id="dialogo" header="Dados da empresa" widgetVar="dlgEmpresa" resizable="false"   
              modal="true" appendToBody="true">
        <ui:include src="add.xhtml" />
        <!--     confirmação para excluir de participante do evento       -->
        <p:confirmDialog id="confirmDialog" message="Confirma excluir este empresa?" appendToBody="true"
                         header="Atenção!!!" severity="alert" widgetVar="confirmationExcluirgrupo" > 
            <h:form>
                <p:commandButton id="confirm" value="Sim" oncomplete="confirmationExcluirgrupo.hide()"  
                                 actionListener="#{empresaControler.excluir()}" update=":formTabela"/>  
                <p:commandButton id="decline" value="Cancelar" onclick="confirmationExcluirgrupo.hide()" type="button" />   
            </h:form>
        </p:confirmDialog>
    </p:dialog>
</html>